/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-09-07 19:53:25
 * @LastEditors  : 飞越疯人院 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\SecurityActivity.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import {
    AddDataButton,
    ModDataButton,
    DelDataButton,
    OpenTwoRouter,
    OrdinaryQRCodeButton,
    SelectExcelButton,
    SaveExcelButton,
    OpenSelection,
} from '../Common/options'

export const SecurityActivity = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, dataType: 0 },
        get: API_LIST()[`get${url}OC`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        independenceSet: {
            title: '组织机构',
            url: 'getOrgTree',
            data: { IsByUserUuid: 1 },
            type: 'TableNavTree001',
            all: true,
        },
        independence: 'organizationUuid',
        initialValues: { dataType: 0 },
        options: e => {
            return [
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />,
                e && (
                    <SelectExcelButton
                        key="excel"
                        title="导出活动列表"
                        OptionsEvent={OptionsEvent}
                        api={API_LIST()['getSecurityActivitieExcelList']}
                        data={{ organizationUuid: e }}
                    />
                ),
                <OpenSelection
                    OptionsEvent={OptionsEvent}
                    title="批量删除"
                    type="primary"
                    danger
                    data={{ type: 'SelectionDelete', url: 'posSecurityActivityBatchRemove' }}
                />,
            ]
        },
        columns: [
            commonTableList.uuid,
            {
                title: 'dataType',
                dataIndex: 'dataType',
                search: false,
                valueType: 'hidden',
                hideInTable: true,
                hideInSearch: true,
            },
            {
                ...commonTableList.organizationUuid,
                valueEnum: ClientData.organization,
                title: '单位',
                hideInSearch: true,
                width: 300,
            },
            { ...commonTableList.tableName, title: '主题' },
            {
                dataIndex: 'interval',
                title: '活动时长',
                valueType: 'input',
                ellipsis: true,
                width: 200,
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'startTime',
                title: '开始时间',
                valueType: 'Date',
                showTime: true,
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'endTime',
                title: '结束时间',
                valueType: 'Date',
                showTime: true,
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'trainingMethod',
                title: '培训方式',
                valueType: 'select',
                valueEnum: { 自培: '自培', 外培: '外培' },
                ellipsis: true,
                rules: true,
                width: 200,
            },

            {
                dataIndex: 'department',
                title: '部门',
                valueType: 'input',
                ellipsis: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'trainingType',
                title: '培训类别',
                valueType: 'select',
                valueEnum: { 安全教育: '安全教育', 安全活动: '安全活动' },
                ellipsis: true,
                width: 200,
            },
            {
                dataIndex: 'trainingWorkType',
                title: '培训工种',
                valueType: 'select',
                valueEnum: { 特殊工种: '特殊工种', 安管人员: '安管人员' },
                ellipsis: true,
                width: 200,
            },
            {
                dataIndex: 'teacher',
                title: '授课教师',
                valueType: 'input',
                ellipsis: true,
                width: 200,
            },
            {
                dataIndex: 'trainingContent',
                title: '培训内容',
                valueType: 'input',
                ellipsis: true,
                width: 200,
            },
            {
                dataIndex: 'trainingLocation',
                title: '培训地点',
                valueType: 'input',
                ellipsis: true,
                width: 200,
                hideInSearch: true,
            },
            commonTableList.BeginDate,
            commonTableList.EndDate,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 280,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid } = record
                    return [
                        <OpenTwoRouter
                            key="A01"
                            title="活动附件"
                            twoTitle="安全活动附件管理"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'SecurityActivityAnnex',
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <OpenTwoRouter
                            key="A02"
                            title="参与人员"
                            twoTitle="安全活动参与人员"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'SecurityActivityPerson',
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <SaveExcelButton
                            key="excel"
                            title="下载报告"
                            OptionsEvent={OptionsEvent}
                            api={API_LIST()['getSecurityActivitieWordByUuid']}
                            data={{ uuid }}
                        />,
                        <OrdinaryQRCodeButton
                            key="qrcode"
                            title="活动二维码"
                            OptionsEvent={OptionsEvent}
                            data={{ url: record.uuid }}
                        />,
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
